[SUBROUTINE]
version = 1.14
icon = drill-irr-circle.png
name = _("Drill Irr Circle")
type = drill_cir_irr
help = _("<b>Drill Irregular Circle</b>")
order = act fcut hdr5 cx cy d hdr6 num h1 h2 h3 h4 h5 h6 center hdr3 s u_s ugc dpt u_dpt ugcd

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1

[PARAM_FCUT]
name = _("Show design")
icon = glasses.png
type = bool
value = 1

[PARAM_HDR5]
name = _("Coords, size")
type = sub-header

[PARAM_HDR6]
type = sub-header
name = _("Count, positions")

[PARAM_HDR3]
type = sub-header
name = _("Drilling params")

[PARAM_CX]
name = _("cX")
type = float
icon = center.png
tool_tip = _("Center of circle")
value = 0
metric_value = 0.0
header = hdr5

[PARAM_CY]
name = _("cY")
type = float
icon = center.png
tool_tip = _("Center of circle")
value = 0
metric_value = 0.0
header = hdr5

[PARAM_D]
name = _("Diameter")
type = float
minimum_value = 0.0
icon = diameter.png
tool_tip = _("Diameter of circle")
value = 2
metric_value = 50
header = hdr5
not_allowed = 0

[PARAM_CENTER]
name = _("Drill center")
type = bool
icon = drill-in-center.png
value = 0
tool_tip = _("Drill also at center")
header = hdr6

[PARAM_NUM]
name = _("Number of holes")
type = int
minimum_value = 1
maximum_value = 6
icon = copies-holes.png
tool_tip = _("Number of holes")
value = 3
header = hdr6

[PARAM_H1]
name = _("Hole 1 At")
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle")
value = 10
header = hdr6
suffix = &#176;

[PARAM_H2]
name = _("Hole 2 At")
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle")
value = 60
header = hdr6
suffix = &#176;

[PARAM_H3]
name = _("Hole 3 At")
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle")
value = 120
header = hdr6
suffix = &#176;

[PARAM_H4]
name = _("Hole 4 At")
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle")
value = 0
header = hdr6
suffix = &#176;

[PARAM_H5]
name = _("Hole 5 At")
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle")
value = 0
header = hdr6
suffix = &#176;

[PARAM_H6]
name = _("Hole 6 At")
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle")
value = 0
header = hdr6
suffix = &#176;

[PARAM_S]
name = _("Drill start")
type = combo-user
options = _("User defined=0:Surface=1:Half=2:One quarter=3:Three quarter=4:G-Code=5")
icon = drill-start.png
tool_tip = _("Pre or user defined")
value = 1
header = hdr3
links = u_s=0:ugc=5

[PARAM_U_S]
name = _("User start")
type = float
value = 0.0
metric_value = 0.0
header = hdr3
hidden = 1

[PARAM_UGC]
name = User gcode
type = gcode
value = 
header = hdr3
hidden = 1

[PARAM_UGCD]
name = User depth gcode
type = gcode
value =
header = hdr3
hidden = 1

[PARAM_DPT]
name = _("Cut down to")
type = combo-user
options = _("User defined=0:Through=1:Center drill depth=2:Bottom=3:Half=4:One quarter=5:Three quarter=6:G-Code=7")
icon = drill-end.png
tool_tip = _("Pre or user defined")
value = 1
header = hdr3
links = u_dpt=0:ugcd=7

[PARAM_U_DPT]
name = _("User depth")
type = float
value = -0.5
metric_value = -12.0
header = hdr3
hidden = 1

[DEFINITIONS]
content =
;	<eval>self.include_once(file name here)</eval>

[CALL]
content =
	(begin #sub_name)
	(drill irregular circle of #param_num holes author : Fernand Veilleux)
	
	o<#self_id_active> if [#param_act AND [#<_tool_usage> EQ 3]]
		o<select> CALL [31] [#param_s] [#param_u_s] [#<surface>] [#<surface> - #<wp_depth> / 2] [#<surface> - #<wp_depth> / 4] [#<bottom> + #<wp_depth> / 4] [#param_ugc]
		o<select> CALL [32] [#param_dpt] [#param_u_dpt] [#<bottom_through>] [#31 + #<center_drill_depth>] [#<bottom>] [#<surface> - #<wp_depth> / 2] [#<surface> - #<wp_depth> / 4] [#<bottom> + #<wp_depth> / 4] [#param_ugcd]
	
		o<set_spindle_rpm> CALL [#<_drill_rpm>] [#<_drill_feed>]
	
		o<#self_id_center> if [#param_center]
			o<drill_single> CALL [#param_cx] [#param_cy] [#31] [#32] [#<drill_diameter>] [#<drill_point_len>] [#param_fcut]
		o<#self_id_center> endif
		
		#<radius#ID> = [#param_d / 2]
		#<i#ID> = 0
		o<#self_id_loop> while [#<i#ID> LT #param_num]
			o<#self_id_i> if [#<i#ID> EQ 0]
				o<rotate_xy> CALL [#<radius#ID>] [0] [0] [0] [#param_h1]
			o<#self_id_i> elseif [#<i#ID> EQ 1]
				o<rotate_xy> CALL [#<radius#ID>] [0] [0] [0] [#param_h2]
			o<#self_id_i> elseif [#<i#ID> EQ 2]
				o<rotate_xy> CALL [#<radius#ID>] [0] [0] [0] [#param_h3]
			o<#self_id_i> elseif [#<i#ID> EQ 3]
				o<rotate_xy> CALL [#<radius#ID>] [0] [0] [0] [#param_h4]
			o<#self_id_i> elseif [#<i#ID> EQ 4]
				o<rotate_xy> CALL [#<radius#ID>] [0] [0] [0] [#param_h5]
			o<#self_id_i> else
				o<rotate_xy> CALL [#<radius#ID>] [0] [0] [0] [#param_h6]
			o<#self_id_i> endif
		
			o<drill_single> CALL [#param_cx + #<_rotated_x>] [#param_cy + #<_rotated_y>] [#31] [#32] [#<drill_diameter>] [#<drill_point_len>] [#param_fcut]
			#<i#ID> = [#<i#ID> + 1]
		o<#self_id_loop> endwhile
		
		o<#self_id_stop> if [#<_spindle_all_time> EQ 0]
			M9 M5
		o<#self_id_stop> endif
	
		o<#self_id_active> endif
	(end #sub_name)
